/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package com.ultrasoft.farmasoft.domain;

import java.io.Serializable;
import java.util.Collection;
import javax.persistence.Basic;
import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.EmbeddedId;
import javax.persistence.Entity;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.OneToMany;
import javax.persistence.Table;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlTransient;

/**
 *
 * @author Administrador
 */
@Entity
@Table(name = "submenuprovider")
@XmlRootElement
@NamedQueries({
    @NamedQuery(name = "Submenuprovider.findAll", query = "SELECT s FROM Submenuprovider s"),
    @NamedQuery(name = "Submenuprovider.findByMenuProviderId", query = "SELECT s FROM Submenuprovider s WHERE s.submenuproviderPK.menuProviderId = :menuProviderId"),
    @NamedQuery(name = "Submenuprovider.findBySubmenuProviderId", query = "SELECT s FROM Submenuprovider s WHERE s.submenuproviderPK.submenuProviderId = :submenuProviderId"),
    @NamedQuery(name = "Submenuprovider.findByName", query = "SELECT s FROM Submenuprovider s WHERE s.name = :name"),
    @NamedQuery(name = "Submenuprovider.findByUrl", query = "SELECT s FROM Submenuprovider s WHERE s.url = :url"),
    @NamedQuery(name = "Submenuprovider.findByOrder", query = "SELECT s FROM Submenuprovider s WHERE s.order = :order")})
public class Submenuprovider implements Serializable {
    private static final long serialVersionUID = 1L;
    @EmbeddedId
    protected SubmenuproviderPK submenuproviderPK;
    @Basic(optional = false)
    @Column(name = "name")
    private String name;
    @Basic(optional = false)
    @Column(name = "url")
    private String url;
    @Basic(optional = false)
    @Column(name = "order")
    private short order;
    @JoinColumn(name = "menuProviderId", referencedColumnName = "menuProviderId", insertable = false, updatable = false)
    @ManyToOne(optional = false)
    private Menuprovider menuprovider;
    @OneToMany(cascade = CascadeType.ALL, mappedBy = "submenuprovider")
    private Collection<Optionprovider> optionproviderCollection;

    public Submenuprovider() {
    }

    public Submenuprovider(SubmenuproviderPK submenuproviderPK) {
        this.submenuproviderPK = submenuproviderPK;
    }

    public Submenuprovider(SubmenuproviderPK submenuproviderPK, String name, String url, short order) {
        this.submenuproviderPK = submenuproviderPK;
        this.name = name;
        this.url = url;
        this.order = order;
    }

    public Submenuprovider(short menuProviderId, short submenuProviderId) {
        this.submenuproviderPK = new SubmenuproviderPK(menuProviderId, submenuProviderId);
    }

    public SubmenuproviderPK getSubmenuproviderPK() {
        return submenuproviderPK;
    }

    public void setSubmenuproviderPK(SubmenuproviderPK submenuproviderPK) {
        this.submenuproviderPK = submenuproviderPK;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public String getUrl() {
        return url;
    }

    public void setUrl(String url) {
        this.url = url;
    }

    public short getOrder() {
        return order;
    }

    public void setOrder(short order) {
        this.order = order;
    }

    public Menuprovider getMenuprovider() {
        return menuprovider;
    }

    public void setMenuprovider(Menuprovider menuprovider) {
        this.menuprovider = menuprovider;
    }

    @XmlTransient
    public Collection<Optionprovider> getOptionproviderCollection() {
        return optionproviderCollection;
    }

    public void setOptionproviderCollection(Collection<Optionprovider> optionproviderCollection) {
        this.optionproviderCollection = optionproviderCollection;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (submenuproviderPK != null ? submenuproviderPK.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof Submenuprovider)) {
            return false;
        }
        Submenuprovider other = (Submenuprovider) object;
        if ((this.submenuproviderPK == null && other.submenuproviderPK != null) || (this.submenuproviderPK != null && !this.submenuproviderPK.equals(other.submenuproviderPK))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "com.ultrasoft.farmasoft.domain.Submenuprovider[ submenuproviderPK=" + submenuproviderPK + " ]";
    }
    
}
